import sys

sys.setrecursionlimit(int(1e9))
# 请在此输入您的代码
n = int(input())
board = [list(input()) for _ in range(n)]
will_disappear = []
visited = set()


def dfs(x, y, land_id):
    if board[x][y] == '.': return
    visited.add((x, y))
    # 检查周围是否为陆地
    flag = False
    for nx, ny in [(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)]:
        if not (0 <= nx < n and 0 <= ny < n):
            continue
        if (nx, ny) in visited:
            continue
        if board[nx][ny] == '.':
            flag = True

        dfs(nx, ny, land_id)
    if not flag:  # 只有会被淹没转化为不被淹没的情况
        will_disappear[land_id] = flag


l_id = 0
for i in range(n):
    for j in range(n):
        if board[i][j] == '#' and (i, j) not in visited:
            will_disappear.append(True)
            dfs(i, j, l_id)
            l_id += 1
print(sum(will_disappear))
